﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;

namespace BYS.XiAnComDept.BussLogic
{
    [DisplayColumn("单位")]
    public class Company : IDataErrorInfo
    {
        ValidateEntity<Company> validator = new ValidateEntity<Company>();
        public Company()
        {
            this.ComGuid = Guid.NewGuid();
            this.Funds = new ObservableCollection<Fund>();
        }

        [Key]
        [Editable(false,AllowInitialValue= false)]
        public Guid ComGuid { get; set; }

        [Required(ErrorMessage="单位名称必须输入！")]
        [Display(Name="单位名称")]
        public string CompanyName { get; set; }

        [Display(Name="曾用名")]
        public string CompanyPreName { get; set; }

        public ObservableCollection<Fund> Funds { get; set; }

        [NotMapped]
        string IDataErrorInfo.Error
        {
            get { throw new NotImplementedException(); }
        }

        [NotMapped]
        string IDataErrorInfo.this[string columnName]
        {
            get
            {
                return validator.ValidateProperty(this, columnName);
            }
        }
    }
}
